package A01File;

import java.io.File;

public class FileTest04 {
    public static void main(String[] args) {
        File file = new File("D:\\File\\bb");
        System.out.println(getLen(file) / 1024 / 1024);
    }
    public static long getLen(File file){
        long len = 0;
        File[] files = file.listFiles();
        for (File file1 : files) {
            if(file1.isFile()){
                len += file1.length();
            }else {
                len += getLen(file1);
            }
        }
        return len;
    }
}
